<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>DWR  DEMO</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

  </head>
  <script type='text/javascript' src='/ChinareBi_Demo/dwr/interface/DWRExample.js'></script>
  <script type='text/javascript' src='/ChinareBi_Demo/dwr/engine.js'></script>
  <script type='text/javascript' src='/ChinareBi_Demo/dwr/util.js'></script>
  
  <script type="text/javascript">
  
  function show()
  {
 	 //display list data
 	 alert("ok");
 	 var orgCode = 
    DWRExample.getList(call);
  }
  function call(data)
  {
	  	alert(data);
  	if(data)
  	{
  	var content="name    age<br/>";
  		for(var i=0;i<data.length;i++)
  		{
  			//alert(data[i].name);
  			content+=(data[i].name+"  "+data[i].age+"<br/>")
  		}
  		DWRUtil.setValue("DemoDiv",content);
  	
  	}
  }
  
 
  function validateForm()
  {
 	//validate user name
  	//var name=document.getElementById("name");
  	var name=DWRUtil.getValue("name");

  	if(name==null || name=="")
  	{
  		alert("name is null!");
  	}else
  	{
  		
		DWRExample.checkUser(name,callBack);
			
  	}
  }
  function callBack(data)
  { 	
  	if(data)
  	{
  		//alert("name is right!");
  		//name=='xy' return to current page
  		window.location.href="/ChinareBi_Demo/";
  	}else
  	{
  		alert("name is not exist!");
  	}
  }
  
  </script>
  <body>
    This is my DWR DEOM page. <hr>
    <input id="name"  name="name" value=""/>
    <input  type="button" onclick="call('x',12);"  value=" ok "/>
    
    <br/>
    <div id="DemoDiv">demo</div>
  </body>
</html>
